#ifndef ALIVESENDER_H
#define ALIVESENDER_H

#include <QObject>
#include <QTimer>
#include <QTime>
#include <QDebug>
#include <QUdpSocket>

#ifdef Q_OS_UNIX

	/* Standard POSIX headers */
	#include <netinet/in.h>
	#include <netdb.h>
	#include <sys/socket.h>
	#include <arpa/inet.h>

#endif

#ifdef Q_OS_WIN

	/* WINSOCK header - it suck like windows >_> */
	#include <winsock.h>

#endif

/* Standard headers */
#include <errno.h>
#include <string.h>

#include "User.h"

class AliveSender : public QObject  
{
	Q_OBJECT

private:
	int sock;
	qint16 port;
	unsigned char ttl;
	QTimer *timer;
	bool checkDisconnectedClients;
	struct sockaddr_in multicastAddr;		//Multicast socket address (group + IP)
	struct ip_mreq multicastReq;

private slots:
	void sendAliveMsgOnTimeout();
	
signals:
	void userDisconnected(User *toNotify);

public:
	AliveSender();
	QTimer* getTimer();
	
};
#endif
